//
//  GetAddBuyGoodsCell.m
//  TryShopping
//
//  Created by panquanReabam.com on 16/10/19.
//  Copyright © 2016年 RuiBen. All rights reserved.
//

#import "GetAddBuyGoodsCell.h"

@interface GetAddBuyGoodsCell()

@end
@implementation GetAddBuyGoodsCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //        [self createView];
        //        [self setViewAutoLayout];
    }
    return self;
}


-(void)setGetAddBuyGoodsModel:(GetAddBuyGoodsModel *)GetAddBuyGoodsModel{
    
    
    NSString *s1 =[NSString stringWithFormat:@"%@",GetAddBuyGoodsModel.tagName];
    UIFont *font1 = [UIFont systemFontOfSize:13];
    CGSize size1 = CGSizeMake(ScreenWidth-60, 2000);
    CGSize labelsize1 = [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
    
    _conditions=[[UILabel alloc] initWithFrame:CGRectMake(15, 15, labelsize1.width, 14)];
    [_conditions setText:[NSString stringWithFormat:@"%@",GetAddBuyGoodsModel.tagName]];
    _conditions.font=[UIFont systemFontOfSize:11];
    [_conditions.layer setCornerRadius:2];
    [_conditions.layer setBorderWidth:0.5];
    [_conditions.layer setMasksToBounds:YES];
    _conditions.layer.borderColor=[[UIColor redColor] CGColor];
    _conditions.textAlignment=NSTextAlignmentCenter;
    _conditions.textColor=[UIColor redColor];
    [self addSubview:_conditions];
    
    _conditionsLabel=[[UILabel alloc] initWithFrame:CGRectMake(_conditions.right+5, 15, ScreenWidth-labelsize1.width-30-20-20, 14)];
    [_conditionsLabel setText:[NSString stringWithFormat:@"%@",GetAddBuyGoodsModel.title]];
    _conditionsLabel.font=[UIFont systemFontOfSize:11];
    _conditionsLabel.textColor=[UIColor colorWithRed:102.0/255.0f green:102.0/255.0f  blue:102.0/255.0f  alpha:1.0];
    [self addSubview:_conditionsLabel];
    _chooseBtn1=[[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40, 40, 30,30)];
    _chooseBtn1.userInteractionEnabled=NO;
    [self addSubview:_chooseBtn1];

    if ([GetAddBuyGoodsModel.isAvailable isEqualToString:@"Y"]) {
      
       
 
        if ([GetAddBuyGoodsModel.isCurrent isEqualToString:@"Y"]) {
            [_chooseBtn1 setImage:[UIImage imageNamed:@"gous"] forState:UIControlStateNormal];

        }else{
         [_chooseBtn1 setImage:[UIImage imageNamed:@"quans"] forState:UIControlStateNormal];
        }
        
    }else{
        
        UIImage *img=[UIImage imageNamed:@"gous"];
        UIImage *tinted = [img rt_tintedImageWithColor:qianhuiColor];
        _chooseBtn=[[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40, 40, 30,30)];
         [_chooseBtn setImage:tinted forState:UIControlStateNormal];
        _chooseBtn.userInteractionEnabled=NO;
        [self addSubview:_chooseBtn];


    }
    
    
    
    self.productImageView=[[UIImageView alloc] initWithFrame:CGRectMake(15, 40, 60, 60)];
    _productImageView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _productImageView.layer.borderWidth= 0.5f;
    [_productImageView setImageWithURL:[NSURL URLWithString:GetAddBuyGoodsModel.imageUrl] placeholderImage:[UIImage imageNamed:@"zhengfangxing"]];
    [self addSubview:_productImageView];
    
    NSString *s2 =[NSString stringWithFormat:@"%@",GetAddBuyGoodsModel.itemName];
    UIFont *font2 = [UIFont systemFontOfSize:14];
    CGSize size2 = CGSizeMake(ScreenWidth-140, 2000);
    CGSize labelsize2 = [s2 sizeWithFont:font2 constrainedToSize:size2 lineBreakMode:NSLineBreakByCharWrapping];

    
    _productNameLabel=[[UILabel alloc] initWithFrame:CGRectMake(85, 40, ScreenWidth-130, labelsize2.height)];
    [_productNameLabel setText:GetAddBuyGoodsModel.itemName];
    _productNameLabel.font=[UIFont systemFontOfSize:14];
    _productNameLabel.numberOfLines=2;
    _productNameLabel.textColor=[UIColor colorWithRed:51.0/255.0f green:51.0/255.0f  blue:51.0/255.0f  alpha:1.0];
    [self addSubview:_productNameLabel];
    
    
    if (GetAddBuyGoodsModel.specName==NULL|| [[Global getJudgeTheErrorStr:GetAddBuyGoodsModel.specName]isEqualToString:@""] ) {
        
    }else{
        _productSpecNameLabel=[[UILabel alloc] initWithFrame:CGRectMake(85, 72.5, 200, 13)];
        [_productSpecNameLabel setText:[NSString stringWithFormat:@"%@",GetAddBuyGoodsModel.specName ]];
        _productSpecNameLabel.font=[UIFont systemFontOfSize:12];
        _productSpecNameLabel.textColor=[UIColor colorWithRed:102.0/255.0f green:102.0/255.0f  blue:102.0/255.0f  alpha:1.0];
        [self addSubview:_productSpecNameLabel];
    }
    
    
    _productPriceLabel=[[UILabel alloc] initWithFrame:CGRectMake(85, 87.5, 200, 12)];
    [_productPriceLabel setText:[NSString stringWithFormat:@"¥ %0.02f",[GetAddBuyGoodsModel.salePrice floatValue]]];
    _productPriceLabel.font=[UIFont systemFontOfSize:12];
    _productPriceLabel.textColor=[UIColor colorWithRed:102.0/255.0f green:102.0/255.0f  blue:102.0/255.0f  alpha:1.0];
    [self addSubview:_productPriceLabel];
    _productInvLabel=[[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-125, 85, 110, 13)];
    [_productInvLabel setText:[NSString stringWithFormat:@"x %d",[GetAddBuyGoodsModel.quantity intValue]]];
    _productInvLabel.font=[UIFont systemFontOfSize:13];
    _productInvLabel.textColor=[UIColor colorWithRed:109.0/255.0f green:102.0/255.0f  blue:102.0/255.0f  alpha:1.0];
    NSString *str=[NSString stringWithFormat:@"x %d",[GetAddBuyGoodsModel.quantity intValue]];
    NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:str];
    [attriString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1.0] range:NSMakeRange(0, 2)];
    
    _productInvLabel.attributedText=attriString;
    _productInvLabel.textAlignment=NSTextAlignmentRight;
    [self addSubview:_productInvLabel];
    

    

    self.lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(10, 114, ScreenWidth-20, 0.45)];
    [self.lineLabel setBackgroundColor:qianhuiColor];
    [self addSubview:self.lineLabel];
    
    
}
-(void)setShopCartTrunDonationModel:(ShopCartTrunDonationModel *)ShopCartTrunDonationModel{
    
    
    _chooseBtn1=[[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40, 40, 30,30)];
    _chooseBtn1.userInteractionEnabled=NO;
    [self addSubview:_chooseBtn1];

        if (![_IdArray containsObject:ShopCartTrunDonationModel.id]) {
        
   
            [_chooseBtn1 setImage:[UIImage imageNamed:@"quans"] forState:UIControlStateNormal];
            
        }else{
            [_chooseBtn1 setImage:[UIImage imageNamed:@"gous"] forState:UIControlStateNormal];
        }
        
    
    
    self.productImageView=[[UIImageView alloc] initWithFrame:CGRectMake(15, 20, 82, 82)];
    _productImageView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _productImageView.layer.borderWidth= 0.5f;
    [_productImageView setImageWithURL:[NSURL URLWithString:ShopCartTrunDonationModel.imageUrl] placeholderImage:[UIImage imageNamed:@"zhengfangxing"]];
    [self addSubview:_productImageView];
    
    NSString *s2 =[NSString stringWithFormat:@"%@",ShopCartTrunDonationModel.itemName];
    UIFont *font2 = [UIFont systemFontOfSize:14];
    CGSize size2 = CGSizeMake(ScreenWidth-140, 2000);
    CGSize labelsize2 = [s2 sizeWithFont:font2 constrainedToSize:size2 lineBreakMode:NSLineBreakByCharWrapping];
    
    
    _productNameLabel=[[UILabel alloc] initWithFrame:CGRectMake(107, 20, ScreenWidth-130, labelsize2.height)];
    [_productNameLabel setText:ShopCartTrunDonationModel.itemName];
    _productNameLabel.font=[UIFont systemFontOfSize:14];
    _productNameLabel.numberOfLines=2;
    _productNameLabel.textColor=[UIColor colorWithRed:51.0/255.0f green:51.0/255.0f  blue:51.0/255.0f  alpha:1.0];
    [self addSubview:_productNameLabel];
    
    
    if (ShopCartTrunDonationModel.specName==NULL|| [[Global getJudgeTheErrorStr:ShopCartTrunDonationModel.specName]isEqualToString:@""] ) {
        
    }else{
        _productSpecNameLabel=[[UILabel alloc] initWithFrame:CGRectMake(107, 60, 200, 13)];
        [_productSpecNameLabel setText:[NSString stringWithFormat:@"%@",ShopCartTrunDonationModel.specName ]];
        _productSpecNameLabel.font=[UIFont systemFontOfSize:12];
        _productSpecNameLabel.textColor=[UIColor colorWithRed:102.0/255.0f green:102.0/255.0f  blue:102.0/255.0f  alpha:1.0];
        [self addSubview:_productSpecNameLabel];
    }
    
    
    _productPriceLabel=[[UILabel alloc] initWithFrame:CGRectMake(107, 87.5, 200, 12)];
    [_productPriceLabel setText:[NSString stringWithFormat:@"¥ %0.02f",[ShopCartTrunDonationModel.salePrice floatValue]]];
    _productPriceLabel.font=[UIFont systemFontOfSize:12];
    _productPriceLabel.textColor=hongseColor;
    [self addSubview:_productPriceLabel];
    _productInvLabel=[[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-125, 85, 110, 13)];
    [_productInvLabel setText:[NSString stringWithFormat:@"x %d",[ShopCartTrunDonationModel.quantity intValue]]];
    _productInvLabel.font=[UIFont systemFontOfSize:13];
    _productInvLabel.textColor=[UIColor colorWithRed:109.0/255.0f green:102.0/255.0f  blue:102.0/255.0f  alpha:1.0];
    NSString *str=[NSString stringWithFormat:@"x %d",[ShopCartTrunDonationModel.quantity intValue]];
    NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:str];
    [attriString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1.0] range:NSMakeRange(0, 2)];
    
    _productInvLabel.attributedText=attriString;
    _productInvLabel.textAlignment=NSTextAlignmentRight;
    [self addSubview:_productInvLabel];
    
    
    
    
    self.lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(10, 120, ScreenWidth-20, 0.45)];
    [self.lineLabel setBackgroundColor:qianhuiColor];
    [self addSubview:self.lineLabel];
    
    
}


-(void)chooseBtn:(UIButton*)sender{



}


@end
